<?php
//
//	file: includes/wpi/class_wpi_plugs.php
//	begin: 30/04/2007
//	$Author: christopher $
//	$Revision: 9 $
//	$Date: 2007-09-06 00:48:02 +0000 (Thu, 06 Sep 2007) $
//	license: http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL)
//
//	description: plugs for wordpress integrator

if (!defined('IN_PHPBB'))
{
	die("Hacking attempt");
}

class class_wpi_stats
{
	// @public initialization for stats online
	function read(&$session_fields, &$user_fields)
	{
		global $stats_online, $wpSettings;

		$stats_online->location_pages[PAGE_BLOG] = array('txt' => 'Blog', 'url' => $wpSettings['blogsUri'], 'parms' => $stats_online->mode == 'in_admin' ? array('pane' => 'right') : array());

		return;
	}
}

class class_wpi_head_tail
{
	// @public page header
	function start()
	{
		global $template, $lang, $gen_simple_header, $wpSettings;

		require_once($phpbb_root_path . 'wp-united/mod-settings.' . $phpEx);
		$wpSettings = get_integration_settings();

		//Do a reverse integration?
		if ( $wpSettings['showHdrFtr'] == 'REV' )
		{
			if (empty($gen_simple_header))
			{
				define('WPU_REVERSE_INTEGRATION', true);
				ob_start();
			}
		}

		$template->assign_vars(array(
			'L_BLOG' => $lang['Blog'],
			'U_BLOG' => append_sid($wpSettings['blogsUri']),
			'I_BLOG' => $template->img('menu_blog'),
		);

		if ( !empty($wpHeader) )
		{
			$template->assign_block_vars('switch_wp_dtd', array(
				'WP_DTD' => $lang['WP_DTD'])
			);
		}
		else
		{
			$template->assign_block_vars('switch_phpbb_dtd', array());
		}

		return;
	}

	// @public page tail
	function end()
	{
		global $pfContent, $phpbb_root_path, $phpEx;

		if ( defined('WPU_REVERSE_INTEGRATION') )
		{
			$pfContent = ob_get_contents();
			ob_end_clean();
			//Now insert phpBB into a wordpress page
			include ($phpbb_root_path . 'wp-united/wordpress-entry-point.' . $phpEx);
		}
	}
}

class class_wpi_profile
{
	// @public view profile fields
	function view($view_user)
	{
		global $template, $wpSettings, $user;

		$blog_img = '';
		if  ( $wpSettings != FALSE )
		{
			if ($wpSettings['buttonsProfile'] && $view_user->data['user_wpuint_id'])
			{
				$blog_uri = append_sid($wpSettings['blogsUri'] . "?author=" . $view_user->data['user_wpuint_id']);
				$blog_img = '<a href="' . $blog_uri . '"><img src="' . $user->img('icon_wpu_blog') . '" alt="' . $user->lang('Blog') . '" title="' . $user->lang('Blog') . '" border="0" /></a>';
				$template->set_switch('blog', true);
			}
		}

		$template->assign_vars(array(
			'BLOG_IMG' => $blog_img,
			'L_BLOG' => $user->lang('Blog'),
		);

		return;
	}
}

class class_wpi_privmsgs
{
	// @public display a pm
	function display_message($privmsg, $privmsgs_id)
	{
		global $template, $user, $wpSettings;

		$blog_img = '';
		if  ( $wpSettings != FALSE )
		{
			if (!empty($wpSettings['buttonsPost']) && !empty($privmsg['user_wpublog_id']) )
			{
					$blog_uri = append_sid($wpSettings['blogsUri'] . "?author=" . $privmsg['user_wpublog_id']);
					$blog_img = '<a href="' . $blog_uri . '"><img src="' . $user->img('icon_blog') . '" alt="' . $user->lang('Blog') . '" title="' . $user->lang('Blog') . '" border="0" /></a>';
			}
		}
		$template->assign_vars(array(
			'BLOG_IMG' => $blog_img,
		));

		return;
	}
}
?>